package com.tac.service.wms.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.dao.mes.ProjectMaintenanceDao;
import com.tac.pojo.mes.ProjectMaintenance;
import com.tac.service.wms.ProjectMaintenanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ProjectMaintenanceServiceImpl implements ProjectMaintenanceService {

    @Autowired
    private ProjectMaintenanceDao projectMaintenanceDao;


    //查看项目列表
    public Result<PageInfo<ProjectMaintenance>> getList
    (Integer pageNum,Integer pageSize,String projectName, Date startStartTime, Date startEndTime, Date endStartTime, Date endEndTime, Integer status){
        PageHelper.startPage(pageNum,pageSize);
        List<ProjectMaintenance> list = projectMaintenanceDao.getList(projectName, startStartTime, startEndTime, endStartTime, endEndTime, status);
        PageInfo<ProjectMaintenance> projectMaintenancePageInfo = new PageInfo<>(list);
        return Result.success(projectMaintenancePageInfo);
    }
    //添加项目
    public Result save(ProjectMaintenance projectMaintenance){
        Integer integer = projectMaintenanceDao.save(projectMaintenance);
        if(integer<=0){
            return Result.error("添加项目失败");
        }
        return Result.success(null);
    }
    //删除项目
    public Result remove(List<Integer> ids){
        Integer integer = projectMaintenanceDao.remove(ids);
        if(integer<=0){
            return Result.error("删除项目失败");
        }
        return Result.success(null);
    }
    //修改项目
    public Result update(ProjectMaintenance projectMaintenance){
        Integer integer = projectMaintenanceDao.update(projectMaintenance);
        if(integer<=0){
            return Result.error("修改项目失败");
        }
        return Result.success(null);
    }
}
